package com.daocao.yfb.fragment;

import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import com.daocao.yfb.R;
import com.daocao.yfb.activity.MsgTipsActivity;
import com.daocao.yfb.util.Util;

import static com.daocao.yfb.util.Util.getStatusBarHeight;

/**
 * Created by xsooy-pc on 17-12-4.
 */

public class MainDiscoverFragment extends BaseFragment {
    @BindView(R.id.view_top)
    View viewTop;
    Unbinder unbinder;

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_main_discover;
    }

    @Override
    protected void initView() {
        viewTop.post(new Runnable() {
            @Override
            public void run() {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                    int height = getStatusBarHeight(getContext());
                    if (height == 0) {
                        return;
                    }
                    ViewGroup.LayoutParams lp = viewTop.getLayoutParams();
                    lp.height = height;
                    viewTop.setLayoutParams(lp);
                }
            }
        });
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick(R.id.img_msg_tips)
    public void onViewClicked() {
        Util.startActivity(getActivity(), MsgTipsActivity.class);
    }
}
